package com.mspbots.teams.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author sean.wang
 * @date Created by 2020/02/27
 */
@Configuration
public class ReportsRabbitConfiguration {

    public static final String EXCHANGE_NAME = "msp.reports";
    public static final String MESSAGE_SENT_QUEUE = "report.message.MessageSent";
    public static final String MESSAGE_RECEIVED_QUEUE = "report.message.MessageReceived";
    public static final String BOTS_WORKING_QUEUE = "report.message.BotsWorking";


    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(EXCHANGE_NAME);
    }

    @Bean
    public Queue messageSentQueue() {
        return new Queue(MESSAGE_SENT_QUEUE);
    }

    @Bean
    public Queue messageReceivedQueue() {
        return new Queue(MESSAGE_RECEIVED_QUEUE);
    }

    @Bean
    public Queue botsWorkingQueue() {
        return new Queue(BOTS_WORKING_QUEUE);
    }

    @Bean
    public Binding bindingMessageSentQueue() {
        return BindingBuilder.bind(messageSentQueue()).to(topicExchange()).with(MESSAGE_SENT_QUEUE);
    }

    @Bean
    public Binding bindingMessageReceivedQueue() {
        return BindingBuilder.bind(messageReceivedQueue()).to(topicExchange()).with(MESSAGE_RECEIVED_QUEUE);
    }

    @Bean
    public Binding bindingBotsWorkingQueue() {
        return BindingBuilder.bind(botsWorkingQueue()).to(topicExchange()).with(BOTS_WORKING_QUEUE);
    }

}
